<template>
	<view class="page">
		<view >
			<image class="pic" :src="url" mode="widthFix" @click="preImg" @longpress="download"></image>
		</view>
		
	</view>
</template>

<script>
	import service from '../../../../common/service.js';
	export default {
		data() {
			return {
				imgShow: false,
				index: 0,
				showBtn: false,
				screenHeight: 0,
				imgLength: 0,
				providerList: [],
				data: [],
				detailDec:"",
				url:'',
				id:Math.random()
			}
		},
		onLoad(event) {
			
			this.screenHeight = uni.getSystemInfoSync().windowHeight;
			var data = {};
			try {
				data = JSON.parse(decodeURIComponent(event.query));
			} catch (error) {
				data = JSON.parse(event.query);
			}
			
			this.id = data.id;
			this.url = data.imageUrl;
			//this.url = 'http://io.bukaa.cn/%E9%95%BF%E9%80%94.jpg';
			console.log(this.url);
			//this.getData(data.id); 
		},
		
		methods: {
			download() {
				service.createDownload(this.url)
			},
			
			preImg() {
				var that = this;
				if (that.imgShow) { //防止点击过快导致重复调用 
					return;
				}
				that.imgShow = true;
				setTimeout(() => {
					that.imgShow = false;
				}, 1000);
				setTimeout(() => {
					uni.previewImage({
						current: that.url,
						urls: Array.of(that.url)
					})
				}, 150)
			},
		}
	}
</script>

<style>
	page {
		background-color: #000;
		overflow-y: auto;
	}

	image {
		width: 100%;
		height: auto;
	}
	
	.pic{
		margin: auto;  
		position: absolute;  
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		overflow-y: auto;
	}
</style>
